package com.zbf.web;

import com.alibaba.fastjson.JSON;
import com.zbf.utils.MD5;
import com.zbf.utils.PdfUtils;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/6/9  14:38
 * 描述:
 */
@RestController
public class TestController {

    @Autowired
    private FreeMarkerConfigurer freeMarkerConfigurer;

    @RequestMapping("yulan")
    public void yulanpdf( HttpServletResponse httpServletResponse){
        Map<String,Object> map=new HashMap<>();
        map.put("title","速度就华斯股份");
        map.put("htname","合同名称");
        map.put("content","jhgjsfj近段时间后发散大家都是大数据高端的技术给的几个杀菌灯将发送的框架分布式快捷方式的接口方说翻就翻北京市地方发散大家办法就是的发圣诞节方式的接口放声大哭合法的是jksgdjgdsjsdkjfhjdskhkfjhsdjkfhsjdfhsdjkhfjds");
        map.put("qianming","陈嘉戚");
        List<Map<String,Object>> list=new ArrayList<>();
        list.add(map);
        PdfUtils.preview(freeMarkerConfigurer,"hetong.html",list,httpServletResponse);
    }


    @RequestMapping("addHtong")
    public void addHtongToDianQianzhangJIgou() throws IOException {
        Map<String,Object> map=new HashMap<>();
        map.put("title","速度就华斯股份");
        map.put("htname","合同名称");
        map.put("content","jhgjsfj近段时间后发散大家都是大数据高端的技术给的几个杀菌灯将发送的框架分布式快捷方式的接口方说翻就翻北京市地方发散大家办法就是的发圣诞节方式的接口放声大哭合法的是jksgdjgdsjsdkjfhjdskhkfjhsdjkfhsjdfhsdjkhfjds");
        map.put("qianming","陈嘉戚");

        String string = JSON.toJSONString(map);

        String neirong = MD5.encryptPassword(string, "20210609151040-26");
        Map<String,Object> map1=new HashMap<>();
        map1.put("htcode","20210609151040-26");
        map1.put("content",neirong);

        String remoteServer = PdfUtils.remoteServer(map1, "http://localhost:20000/addQianZhang");

        System.out.println(remoteServer);

    }


    @Autowired
    private MinioClient minioClient;


    @RequestMapping("htistrue")
    public void htTongIdTrue() throws Exception {
        Map<String,Object> map=new HashMap<>();
        map.put("title","速度就华斯股份");
        map.put("htname","合同名称");
        map.put("content","jhgjsfj近段时间后发散大家都是大数据高端的技术给的几个杀菌灯将发送的框架分布式快捷方式的接口方说翻就翻北京市地方发散大家办法就是的发圣诞节方式的接口放声大哭合法的是jksgdjgdsjsdkjfhjdskhkfjhsdjkfhsjdfhsdjkhfjds");
        map.put("qianming","陈嘉戚");

        Map<String, String> images = PdfUtils.uploadToMonio("合同.pdf", minioClient, "images", freeMarkerConfigurer, "hetong.html", map);


    }


    @RequestMapping("shiming")
    public void shiming(@RequestParam String code) throws IOException {
        Map<String,Object> map=new HashMap<>();
        map.put("code",code);

        String remoteServer = PdfUtils.remoteServer(map, "http://localhost:20000/shimingRenZheng");

        Map<String,Object> map1 = JSON.parseObject(remoteServer, Map.class);

        System.out.println(map1.get("code")+"-------->"+map1.get("result"));


    }


}
